package com.lyf.shop.service.impl;

import java.util.List;
import com.lyf.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lyf.shop.mapper.ClassificationMapper;
import com.lyf.shop.domain.Classification;
import com.lyf.shop.service.IClassificationService;

/**
 * 商品分类Service业务层处理
 * 
 * @author lyf
 * @date 2023-02-10
 */
@Service
public class ClassificationServiceImpl implements IClassificationService 
{
    @Autowired
    private ClassificationMapper classificationMapper;

    /**
     * 查询商品分类
     * 
     * @param id 商品分类主键
     * @return 商品分类
     */
    @Override
    public Classification selectClassificationById(Long id)
    {
        return classificationMapper.selectClassificationById(id);
    }

    /**
     * 查询商品分类列表
     * 
     * @param classification 商品分类
     * @return 商品分类
     */
    @Override
    public List<Classification> selectClassificationList(Classification classification)
    {
        return classificationMapper.selectClassificationList(classification);
    }



    /**
     * 新增商品分类
     * 
     * @param classification 商品分类
     * @return 结果
     */
    @Override
    public int insertClassification(Classification classification)
    {
        classification.setCreateTime(DateUtils.getNowDate());
        return classificationMapper.insertClassification(classification);
    }

    /**
     * 修改商品分类
     * 
     * @param classification 商品分类
     * @return 结果
     */
    @Override
    public int updateClassification(Classification classification)
    {
        classification.setUpdateTime(DateUtils.getNowDate());
        return classificationMapper.updateClassification(classification);
    }

    /**
     * 批量删除商品分类
     * 
     * @param ids 需要删除的商品分类主键
     * @return 结果
     */
    @Override
    public int deleteClassificationByIds(Long[] ids)
    {
        return classificationMapper.deleteClassificationByIds(ids);
    }

    /**
     * 删除商品分类信息
     * 
     * @param id 商品分类主键
     * @return 结果
     */
    @Override
    public int deleteClassificationById(Long id)
    {
        return classificationMapper.deleteClassificationById(id);
    }
    /**
     * 根据用户id查询关联的超市与分类id
     * @param userId
     * @return
     */
    @Override
    public List<Classification> getClassificationNameByUserId(Long userId) {
        return classificationMapper.getClassificationNameByUserId(userId);
    }
}
